import React,{useEffect} from 'react'
import { Button, Field, Form } from 'react-vant';
import { ADDLIST }from '../Type/AddType';

interface CITYPROPSTYPE {
    onFinish?:any;
    onFinishEdit?:any;
    obj?:ADDLIST
}
function CityItem(props:CITYPROPSTYPE) {
    let { onFinish ,obj ,onFinishEdit} = props;
    console.log(props);
    
    const [form] = Form.useForm();
    useEffect(()=>{
        form.setFieldsValue({
            ...obj
        })
    },[])
    return (
        <div className='CityItem'>
            <Form
            form={form}
            showValidateMessage={false}
            onFinish={onFinish ? onFinish : onFinishEdit}
            footer={
                <div style={{ margin: '16px 16px 0' }}>
                <Button round nativeType="submit" type="primary" block>
                    提交
                </Button>
                </div>
            }
            >
            <Form.Item rules={[{ required: true, message: '请填写姓名' }]} name="user" label="姓名">
                <Field placeholder="请输入姓名" />
            </Form.Item>
            <Form.Item rules={[{ required: true, message: '请填写电话' }]} name="tel" label="电话">
                <Field placeholder="请输入电话" />
            </Form.Item>
            <Form.Item rules={[{ required: true, message: '请填写地址' }]} name="city" label="地址">
                <Field placeholder="请输入地址" />
            </Form.Item>
            </Form>
        </div>
    )
}

export default CityItem